// 加载express框架
let express = require("express");
//创建应用服务
let app = express();
//加载ejs模板引擎
let ejs = require("ejs");
app.set("view engine", "html");//启用html引擎
app.set("views", __dirname + "/view");//加载视图目录
app.engine("html", ejs.__express);//识别html后缀名
//加载静态资源文件目录
app.use(express.static(__dirname + "/static"));

//获取表单提交数据
app.use(express.urlencoded({ extended: false }));


//加载模块
let loginRouter = require("./login");
let regRouter = require("./register");
//路由层中间件配置路由
app.use("/user", loginRouter);
app.use("/user", regRouter);


//监听端口
app.listen(4000, "127.0.0.1", () => {
    console.log("启动")
})